//
//  test_model.swift
//  CooperSwift_Example
//
//  Created by 计海峰 on 2021/6/13.
//  Copyright © 2021 CocoaPods. All rights reserved.
//

import Foundation
import HandyJSON
import CooperSwift

struct ProvinceModel: HandyJSON {
    var id: Int?
    var province: String?
    var provinceAllFirstLetter: String?
    var provinceAllLetter: String?
    var provinceId: Int?
}

struct CityModel: HandyJSON {
    var id: Int?
    var cityId: Int?
    var provinceId: Int?
    var cityOpen: Int?
    var cityOpenStr: String?
    var city: String?
    var cityAllFirstLetter: String?
    var cityAllLetter: String?
    var cityHot: Int?
    var cityHotStr: String?
}


struct ResultModel: ResultProtocol {
    
    var success: Bool?
    var data: Any?
    var message: String?
    var msg: String?
    var code: Int?
    var error: Int?
    
    func serviceCode() -> String {
        return "\(self.code ?? 0)"
    }
    
    func serviceMsg() -> String {
        return "\(self.message ?? (self.msg ?? ""))"
    }
    
    func isSuccess() -> Bool {
        return 0 == code
    }
    
    func run(_ tag: String?) {
        
    }
    
    func toastMsg(_ tag: String?) -> String! {
        if "xxx" == tag {
            return self.isSuccess() ? "大西瓜" : "小苹果"
        }
        return self.msg ?? ""
    }
    
    func result_data() -> Any? {
        return self.data
    }
    
}
